#pragma once
#include <QThread>
#include <mutex>
#include <list>
class XDecode;
class XAudioPlay;
class XResample;

struct AVPacket;

struct AVCodecParameters;
class XAudioThread:public QThread
{
public:
	//不管成功与否都清理
	//当前播放音频的pts

	long long pts = 0;
	virtual bool Open(AVCodecParameters *para, int sampleRate, int channels);
	virtual void Push(AVPacket *pkt);//生产者消费者模型
	void run();
	XAudioThread();
	virtual ~XAudioThread();
	int maxList = 200;
	bool isExit = false;
	

protected:
	std::list <AVPacket *> packs;
	std::mutex audiomux;
	XDecode *decode = 0;
	XAudioPlay *ap = 0;
	XResample *res = 0;
};

